export default{
	namespaced:true,
	state:() => ({
		address:JSON.parse(uni.getStorageSync('address') || '{}'),
		token:uni.getStorageSync('token' || ''),
		// 用户信息
		userInfo:JSON.parse(uni.getStorageSync('userInfo') || '{}'),
		redirectInfo:null
	}),
	mutations:{
		// 改变收货地址方法
		setAddress(state,address) {
			state.address = address
			this.commit('m_user/saveAddressStorage')
		},
		// 收货地址本地存储方法
		saveAddressStorage(state){
			uni.setStorageSync('address',JSON.stringify(state.address))
		},
		// 获取userInfo方法
		addUserInfo(state,userInfo){
			state.userInfo = userInfo
			
			this.commit('m_user/saveUserInfoStorage')
		},
		//本地存储用户信息
		saveUserInfoStorage(state) {
			uni.setStorageSync('userInfo',JSON.stringify(state.userInfo))
		},
		// 获取token信息
		addToken(state,token){
			state.token = token
			this.commit('m_user/saveTokenStorage')
		},
		// 本地存储token
		saveTokenStorage(state){
			uni.setStorageSync('token',state.token)
		},
		// 跳转回购物车页面方法
		navRedirecInfo(state,info) {
			state.redirectInfo = info
			console.log(info)
		}
	},
	getters:{
		addStr(state) {
			if(state.address.provinceName == '') return ''
			 return state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
		}
	}
}